package com.movie.service;

import java.io.FileInputStream;
import java.util.Properties;

import com.movie.dao.UserDao;

public class UserService {
	
	private static Properties p = new Properties();
	private static String userDataSource = null;
	
	public static UserDao createUserDao(){
		UserDao userDao = null;
		try {
			String path = Thread.currentThread().getContextClassLoader().getResource  ("user_data_source.properties").getPath();
			FileInputStream inputStream = new FileInputStream(path);
			p.load(inputStream);
			userDataSource = p.getProperty("UserDataSource");
			Class<?> cls = Class.forName(userDataSource);
			Object instance = cls.newInstance();
			userDao = (UserDao) instance;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return userDao;
	}
}
